﻿/*
 *	Copyright (c) 2009 Queensland University of Technology. All rights reserved.
 *	The QUT Bioinformatics Collection is open source software released under the 
 *	Microsoft Public License (Ms-PL): http://www.microsoft.com/opensource/licenses.mspx.
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace QUT.Bio.Util {
	public partial class Tool : UserControl {
		public event Action Action;

		private bool mouseDown;
		
		public Tool () {
			InitializeComponent();
		}
		
		public string Label {
			get {
				return button.Text;
			}
			set {
				button.Text = value;
			}
		}

		private void button_MouseEnter ( object sender, MouseEventArgs e ) {
			button.TextDecorations = TextDecorations.Underline;
		}

		private void button_MouseLeave ( object sender, MouseEventArgs e ) {
			button.TextDecorations = default( TextDecorationCollection );
			mouseDown = false;
		}

		private void button_MouseLeftButtonDown ( object sender, MouseButtonEventArgs e ) {
			mouseDown = true;
		}

		private void button_MouseLeftButtonUp ( object sender, MouseButtonEventArgs e ) {
			if ( mouseDown ) {
				mouseDown = false;
				if ( Action != null ) {
					Action();
				}
			}
		}
	}
}
